package net.hn.hnms.biz.mine.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import net.hn.hnms.biz.api.safety.monitor.model.FloodIndicatorVo;
import net.hn.hnms.biz.mine.domain.dto.WaterDamageWarningInfoPageDto;
import net.hn.hnms.biz.mine.domain.vo.WaterDamageWarningInfoVo;
import net.hn.hnms.biz.mine.service.GasService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 智呈物联 pan'sx
 * 2022/9/28 10:59
 * 1.0 version
 */
@RestController
@RequestMapping("flood/earlyWarning")
@Api(value = "水害预警控制器", tags = {"水害预警"})
@RequiredArgsConstructor
public class FloodEarlyWarningController {
    private final GasService gasService;
    @GetMapping("floodIndicator")
    @ApiOperation("水害评分")
    @AutoSetMineCode
    public R<FloodIndicatorVo> floodIndicator(String mineCode) {
        return R.ok(gasService.floodIndicator(mineCode));
    }

    @GetMapping("waterDamageWarningInfo")
    @ApiOperation("水害报警预警信息（当天）")
    @AutoSetMineCode
    public R<List<WaterDamageWarningInfoVo>> waterDamageWarningInf(@ApiParam(value = "煤矿编码") String mineCode) {
        List<WaterDamageWarningInfoVo> waterDamageWarningInfoVoList= gasService.waterDamageWarningInf(mineCode);
        if (waterDamageWarningInfoVoList.isEmpty()) {
            return R.ok(new ArrayList<>());
        }
        return R.ok(waterDamageWarningInfoVoList);
    }

    @GetMapping("waterDamageWarningInfoPageList")
    @ApiOperation("水害报警预警信息分页查询")
    @AutoSetMineCode
    public R<ResponsePage<WaterDamageWarningInfoVo>> waterDamageWarningInfoPageList(PageQuery pageQuery, WaterDamageWarningInfoPageDto waterDamageWarningInfoPageDto) {
//        if (pageQuery.getPageNum() != null) {
//            pageQuery.setPageNum(pageQuery.getPageNum() + 1);
//        }
        ResponsePage<WaterDamageWarningInfoVo> waterDamageWarningInfoVoListPage= gasService.waterDamageWarningInfoPageList(pageQuery,waterDamageWarningInfoPageDto);
        return R.ok(waterDamageWarningInfoVoListPage);
    }

    @GetMapping("waterDamageWarningInfoType")
    @ApiOperation("水害报警预警类型")
    @AutoSetMineCode
    public R<Map<String, String>> waterDamageWarningInfoType() {
        Map<String, String> map = gasService.waterDamageWarningInfoType();

        return R.ok(map);
    }
}
